Parameters
- value
- The object to use as the value of the element to add.
Exception | Description |
---|---|
System.ArgumentException | An element with the same value already exists in the IList. |
System.NotSupportedException | The IList is read-only. |
Library/Library.Test/TestBTreeList.cs
C# | Copy Code |
---|---|
BTreeList<int> test = new BTreeList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); IList<int> list = test; for (int i = 10; i < 1000; i++) test.Add(i); for(int i=900; i >0; i-=100) { Assert.IsTrue(test.Contains(i)); Assert.AreEqual(i, list.IndexOf(i)); list.RemoveAt(i); Assert.IsFalse(test.Contains(i)); Assert.AreEqual(-1, list.IndexOf(i)); Assert.AreEqual(i + 1, list[i]); } list.RemoveAt(0); list.RemoveAt(1); list.RemoveAt(2); Assert.AreEqual(1, list[0]); Assert.AreEqual(3, list[1]); Assert.AreEqual(5, list[2]); Assert.AreEqual(1000 - 12, list.Count); |
VB.NET | Copy Code |
---|---|
Dim test As New BTreeList(Of Integer)(New Integer() {0, 1, 2, 3, 4, 5, _ 6, 7, 8, 9}) Dim list As IList(Of Integer) = test Dim i As Integer = 10 While i < 1000 test.Add(i) System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1) End While Dim i As Integer = 900 While i > 0 Assert.IsTrue(test.Contains(i)) Assert.AreEqual(i, list.IndexOf(i)) list.RemoveAt(i) Assert.IsFalse(test.Contains(i)) Assert.AreEqual(-1, list.IndexOf(i)) Assert.AreEqual(i + 1, list(i)) i -= 100 End While list.RemoveAt(0) list.RemoveAt(1) list.RemoveAt(2) Assert.AreEqual(1, list(0)) Assert.AreEqual(3, list(1)) Assert.AreEqual(5, list(2)) Assert.AreEqual(1000 - 12, list.Count) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
BTreeList<T> ClassBTreeList<T> Members